package handlers

import (
	"car-trade-sys/model"
	"github.com/gin-gonic/gin"
)

func CarAdd(c *gin.Context) {
	carName := c.PostForm("carName")
	carCode := c.PostForm("carCode")
	carNo := c.PostForm("carNo")
	car := model.Car{
		CarName: carName,
		CarCode: carCode,
		CarNo:   carNo,
	}
	err := model.DB.Create(&car).Error
	if err != nil {
		c.JSON(200, gin.H{
			"code": 400,
			"msg":  "添加失败",
		})
		return
	}
	c.JSON(200, gin.H{
		"code": 200,
		"msg":  "添加成功",
	})
}
